<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateFeishuCallingCardUsersStoriesLog extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('feishu_calling_card_users_stories_log', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('storiesId')->default(0)->comment('文章ID 加盟商故事文章表id');
            $table->unsignedInteger('usersId')->default(0)->comment('用户ID 加盟商名片微信小程序用户表id');
            $table->unsignedInteger('openTime')->default(0)->comment('进入时间');
            $table->unsignedInteger('exitTime')->default(0)->comment('离开时间');
            $table->unsignedInteger('duration')->default(0)->comment('阅读时长');
            $table->unsignedTinyInteger('isReadCompleted')->default(0)->comment('0 否 1 是 是否完成阅读');
            $table->unsignedTinyInteger('isClickJoin')->default(0)->comment('0 否 1 是 是否点击加盟');
            $table->unsignedTinyInteger('type')->default(0)->comment('类型 1-进入文章 2-心跳更新数据 3-离开事件(更新数据) 4-脚本自动关闭');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '加盟商名片微信小程序用户查看文章记录表';

            $table->index('storiesId', 'idx_storiesId');
            $table->index('usersId', 'idx_usersId');
            $table->index('openTime', 'idx_openTime');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('feishu_calling_card_users_stories_log');
    }
}
